<template>
  <div class="case-detatil">
    <template v-if="productType === PRODUCTTYPE.JXD">
      <config-form :initData="basicForm"  :span="6"  :options="BASIC_FORM[approvalData.flag]"/>
      <config-form
        v-if=" basicForm.caseStatus !== 'APPLY_SUBMIT' && basicForm.caseStatus !== 'WAIT_ASSIGN' && approvalData.flag === 'Q'"
        :initData="basicForm"
        :span="6"
        :options="STEP_FORM['APPLY_CONFIRM']"
      />
      <config-form
        v-if="basicForm.caseStatus !== 'APPLY_SUBMIT' && basicForm.caseStatus !== 'WAIT_ASSIGN' && basicForm.caseStatus !== 'APPLY_CONFIRM' &&
            basicForm.caseStatus !== 'PRE_AUDIT' && basicForm.caseStatus !== 'APPLY_CANCEL' && isPreReje && approvalData.flag === 'Q'"
        :initData="basicForm"
        :span="12"
        :options="STEP_FORM['PRE_CONFIRM']"
      />
      <config-form
        v-if="basicForm.caseStatus !== 'APPLY_SUBMIT' 
        && basicForm.caseStatus !== 'WAIT_ASSIGN' 
        && basicForm.caseStatus !== 'APPLY_CONFIRM' &&
            basicForm.caseStatus !== 'PRE_AUDIT' 
            && basicForm.caseStatus !== 'APPLY_CANCEL' && isPreReje "
        :initData="basicForm"
        :span="6"
        :options="STEP_FORM['PRE_CONFIRM_2']"
      />
      <config-form
        v-if="basicForm.caseStatus === 'QUOTA_COMPLETE' && approvalData.flag === 'Q'"
        :initData="applyData"
        :span="6"
        :options="STEP_FORM['RESEARCH']"
      />
    </template>
    <template v-if="productType === PRODUCTTYPE.JYD">
      <template v-if="approvalData.flag === 'A'">
        <config-form
          :initData="basicForm"
          :span="6"
          :options="BASIC_FORM2[approvalData.flag]"
        />
      </template>
      <template v-if="approvalData.flag === 'Q'">
        <config-form
          :initData="basicForm"
          :span="6"
          :options="BASIC_FORM2['Q']"
        />
        <template>
          <config-form
            v-if="
              basicForm.caseStatus != 'APPLY_SUBMIT' &&
                basicForm.caseStatus != 'FIRST_FILTER' &&
                approvalData.flag === 'Q'
            "
            :initData="basicForm"
            :span="6"
            :options="BASIC_FORM2['Q2']"
          />
          <config-form
            v-else
            :initData="basicForm"
            :span="6"
            :options="BASIC_FORM2['Q4']"
          />
        </template>
        <config-form
          :initData="basicForm"
          :span="6"
          :options="BASIC_FORM2['Q3']"
        />
        <config-form
          v-if="
            basicForm.caseStatus === 'APPROVE_CONFIRM' ||
              basicForm.caseStatus === 'MORTGAGE_AUDIT' ||
              basicForm.caseStatus === 'IMPLEMENT_MORTGAGE' ||
              (basicForm.caseStatus === 'LOAN_COMPLETE' &&
                approvalData.flag === 'Q')
          "
          :initData="basicForm"
          :span="6"
          :options="STEP_FORM['ASSESSMENT_AMOUNT']"
        />
      </template>
    </template>

    <flow-record :caseStatus="basicForm.caseStatus" />
    <el-tabs v-model="activeName">
      <el-tab-pane
        v-if="productType === PRODUCTTYPE.JYD"
        label="申请信息"
        name="apply"
      >
        <jyd-apply-info :caseStatus="caseStatus" />
      </el-tab-pane>
      <el-tab-pane
        v-if="productType === PRODUCTTYPE.JXD"
        label="申请信息"
        name="apply"
        :caseStatus="caseStatus"
      >
        <apply-info />
      </el-tab-pane>
      <el-tab-pane
        label="房产信息"
        name="estate"
        v-if="productType === PRODUCTTYPE.JYD"
      >
        <estate-info :caseStatus="caseStatus" :assForm="assForm" />
      </el-tab-pane>
      <el-tab-pane :label="`跟进记录(${followList.length})`" name="follow">
        <record-list :headList="FOLLOW_HEAD_LIST" :recordList="followList" />
      </el-tab-pane>
      <el-tab-pane
        :label="`审批记录(${approvalRecordList.length})`"
        name="approval"
      >
        <record-list
          :headList="APPROVAL_HEAD_LIST"
          :recordList="approvalRecordList"
        />
      </el-tab-pane>
    </el-tabs>
    <template v-if="productType == PRODUCTTYPE.JXD">
      <el-tabs v-model="imageActive">
        <el-tab-pane
          v-for="(value, key) in IMAGE_TYPE"
          :key="key"
          :label="value + '(' + imageAll[key].length + ')'"
          :name="key"
        >
          <image-preview
            :imageList="imageAll[key]"
            :previewList="previewList[key]"
          ></image-preview>
        </el-tab-pane>
      </el-tabs>
    </template>
    <template v-if="productType == PRODUCTTYPE.JYD">
      <el-tabs v-model="imageActive">
        <el-tab-pane
          v-for="(value, key) in IMAGE_JYDTYPE"
          :key="key"
          :label="value + '(' + jydimageAll[key].length + ')'"
          :name="key"
        >
          <image-preview
            :imageList="jydimageAll[key]"
            :previewList="jydPreviewList[key]"
          ></image-preview>
        </el-tab-pane>
      </el-tabs>
    </template>

    <el-tabs v-model="agreementActive" style="margin-bottom: 50px;">
      <el-tab-pane
        v-for="(value, key) in contractType"
        :key="key"
        :label="value + '(' + allContract[key].length + ')'"
        :name="key"
      >
        <template v-if="productType == PRODUCTTYPE.JXD">
          <image-preview
            :imageList="allContract[key]"
            :previewList="previewList[key]"
          ></image-preview>
        </template>
        <template v-if="productType == PRODUCTTYPE.JYD">
          <image-preview
            :imageList="allContract[key]"
            :previewList="jydPreviewList[key]"
          ></image-preview>
        </template>
      </el-tab-pane>
    </el-tabs>
    <audit :productType="productType" v-if="flag !== 'Q'" />
  </div>
</template>

<script>
import EstateInfo from "./EstateInfo";
import FlowRecord from "./FlowRecord";
import ApplyInfo from "./ApplyInfo";
import JydApplyInfo from "./JydApplyInfo";
import RecordList from "./RecordList";
import Audit from "./Audit";
import {
  BASIC_FORM,
  APPROVAL_HEAD_LIST,
  FOLLOW_HEAD_LIST,
  IMAGE_TYPE,
  IMAGE_JYDTYPE,
  STEP_FORM,
  BASIC_FORM2,
  PRODUCTTYPE
} from "../js/contant.js";
import api from "../api";
import { mapState } from "vuex";
import { CONSTANT_OBJ } from "@/utils/constant";
import { formatWithMod, deepCopy } from "@/utils/util";
export default {
  components: {
    FlowRecord,
    ApplyInfo,
    RecordList,
    Audit,
    EstateInfo,
    JydApplyInfo
  },
  props: ["flag"],
  data() {
    return {
      BASIC_FORM,
      BASIC_FORM2,
      FOLLOW_HEAD_LIST,
      APPROVAL_HEAD_LIST,
      IMAGE_TYPE,
      PRODUCTTYPE,
      IMAGE_JYDTYPE,
      STEP_FORM,
      // CON_IMG,
      basicForm: {},
      assForm: {},
      activeName: "apply",
      approvalRecordList: [],
      followList: [],
      imageActive: "TAX",
      imageAll: {
        TAX: [],
        HOUSE_FUND: [],
        INSURANCE: [],
        ASSET: [],
        EDUCATION: [],
        SALARY: [],
        VISIT: [],
        OTHER: []
      },
      jydimageAll: {
        MARRIAGE: [],
        GUARANTEE: [],
        RENT: [],
        VISIT: [],
        CLEAN_PRACTICE: [],
        INCOME: [],
        DUE_DILIGENCE: [],
        OTHER: [],
        HOUSE_FUND_TAX_SALARY: []
      },
      previewList: {
        TAX: [],
        HOUSE_FUND: [],
        INSURANCE: [],
        ASSET: [],
        EDUCATION: [],
        SALARY: [],
        VISIT: [],
        OTHER: []
      },
      jydPreviewList: {
        MARRIAGE: [],
        GUARANTEE: [],
        RENT: [],
        VISIT: [],
        CLEAN_PRACTICE: [],
        INCOME: [],
        DUE_DILIGENCE: [],
        OTHER: [],
        HOUSE_FUND_TAX_SALARY: []
      },
      allContract: {},
      contractType: {},
      agreementActive: "",
      nowStatus: "",
      applyData: {},
      isPreReje: false,
      productType: "",
      caseStatus: ""
    };
  },
  mounted() {
    this.caseStatus = this.$tabParams.caseStatus;
    this.productType = this.$tabParams.productType;
    console.log('产品类型：', this.productType);
    if (this.productType === PRODUCTTYPE.JYD) {
      this.getqueryByCaseId();
    }
    this.getBasicData();
    this.getFollowRecordData();
    this.getApprovalRecordData();
    this.getImageListInformation();
  },
  methods: {
    getqueryByCaseId() {
      const params = {
        caseId: this.approvalData.caseId
      };
      api.queryByCaseId(params)
      .then(res => {
        const { responseCode, data } = res;
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          let result = { ...data } || {};
          this.assForm = deepCopy({}, result)
          console.log('什么玩意一堆坑：', this.assForm);
          // this.assForm = Object.assign(result);
        }
      })
      .catch(()=> {
        console.log('???????');
      })
    },
    // 获取基本数据
    getBasicData() {
      api.getBasicInfoData(this.approvalData.caseId).then(res => {
        const { responseCode, data } = res;
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          let bData = { ...data } || {};
          bData.applyPeriods = this.dicts["jyd_loan_periods"].childMap[
            bData.applyPeriods
          ];
          bData.newApplyAmount = formatWithMod(bData.applyAmount);
          this.getPreApprovalData(bData);
          // this.getContactList(bData)
        }
      });
    },

    // 获取预批数据
    getPreApprovalData(bData) {
      api.getPreApprovalData(this.approvalData.caseId).then(res => {
        const { responseCode, data } = res;
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          let result = { ...data } || {};
          let arr = [];
          this.isPreReje =
            result.approveAmountVos && result.approveAmountVos.length > 0;
          result.approveAmountVos &&
            result.approveAmountVos.forEach(item => {
              arr.push(
                `${formatWithMod(item.suggestAmount)}[${
                  this.dicts["pre_approve_level"].childMap[item.preApproveLevel]
                }]`
              );
            });
          result.preAmount = arr.join("     ");
          result.newProductType = this.dicts["product_type"].childMap[
            bData.productType
          ];
          if (this.productType === PRODUCTTYPE.JYD) {
            result.newCaseStatus = this.dicts["jyd_case_status"].childMap[
              bData.caseStatus
            ];
          }
          if (this.productType === PRODUCTTYPE.JXD) {
            result.newCaseStatus = this.dicts["case_status"].childMap[
              bData.caseStatus
            ];
          }
          // 预计授信最长期数 newPreMaxPeriods 预计授信年利率 newPreSuggestRate
          let rate = result.suggestRate || 0
          let approveXxhbResult = result.approveXxhbResult
          if (approveXxhbResult === 'Y'){
            this.$set(result, 'newPreMaxPeriods', `等额本息${result.suggestMaxPeriods};\n先息后本${result.xxhbPeriodUpperLimit};`)
            this.$set(result, 'newPreSuggestRate', `等额本息${rate * 12}%;\n先息后本${rate * 12}%;`)
          } else {
            this.$set(result, 'newPreMaxPeriods', `等额本息${result.suggestMaxPeriods}`)
            this.$set(result, 'newPreSuggestRate', `等额本息${rate * 12}%;`)
          }
          if (this.productType === PRODUCTTYPE.JXD) {
            this.basicForm = Object.assign(bData, result);
          } else {
            this.basicForm = Object.assign(bData, result, this.assForm);
          }
          if (
            this.basicForm.caseStatus === "QUOTA_COMPLETE" &&
            this.approvalData.flag === "Q"
          ) {
            this.queryScheduleFllowEvent();
          }
          console.log(this.basicForm);
        }
      });
    },
    // 获取最新进度结果
    queryScheduleFllowEvent(bData) {
      api.queryScheduleFllow({ caseId: this.approvalData.caseId }).then(res => {
        const { responseCode, data } = res;
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          data.data.newFee = data.data.rateList
            .map(ele => this.dicts["fee_pay_type"].childMap[ele.feePayType])
            .join(",");
          data.data.newMaxPeriods = data.data.rateList
            .map(
              ele =>
                `${this.dicts["fee_pay_type"].childMap[ele.feePayType]}:${
                  this.dicts["loan_periods"].childMap[ele.maxPeriods]};`
            )
            .join("\n");
          data.data.newIrrRate = data.data.rateList
            .map(
              ele =>
                `${this.dicts["fee_pay_type"].childMap[ele.feePayType]}:${ ele.irrRate }%;`
            )
            .join('\n');
          data.data.newApproveAmount = formatWithMod(data.data.approveAmount);
          this.applyData = { ...data.data };
        }
      });
    },
    /**
     * @description 案件跟进记录
     */
    getFollowRecordData() {
      api.getFollowData(this.approvalData.caseId).then(res => {
        const { responseCode, data } = res;
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          let result = [...data] || [];
          this.followList = result;
        }
      });
    },
    /**
     * @description 通过caseId查询申请件审批记录
     */
    getApprovalRecordData() {
      api.getAuditData(this.approvalData.caseId).then(res => {
        const { responseCode, data } = res;
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          let result = [...data] || [];
          result.forEach(ele => {
            ele.newType = this.dicts["audit_type"].childMap[ele.auditType] || ele.auditType;
            ele.newRes = this.dicts["audit_result"].childMap[ele.auditResult];
            // 审批记录改为 '-'
            ele.auditAdvice = '-'
          });
          this.approvalRecordList = result;
        }
      });
    },
    // 获取影像信息
    getImageListInformation() {
      api.getImageInfo(this.approvalData.caseId).then(res => {
        const { responseCode, data } = res;
        if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
          console.log(data, "影像信息");
          this.disposeImage(data);
          this.disposeContract(data);
        }
      });
    },
    disposeImage(list) {
      // const list = [
      //   {
      //     urls: [
      //       {
      //         fileName: "个人征信授权书20230201191406.pdf",
      //         uploadTime: "20230201191411",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFucyfj52IfXzwlungFCtI5EW7RwDFjkgB7EpRGkGXbKQvFyOiTzetTQIalNawUtL7/TA3duaVCL3I9er/c9pN4zIF970ngqH8sx2o947bPSLMSrxmJxKmf16u+vHEPHpBivYH1pU2lQ/j4Pf41ZG339NW0C39f5cg0ziRT58OquT+QUUwnUSjRc7yjA8q0jL8+mhgtxH6rrnTauq/RqUE4kjJFzgch8deF0HK2mpoHTk+/gGNjvBG4vmQ3ZjSixkxqOUBZUMx4PoaHdvFLhtL0",
      //         fileType: "pdf"
      //       },
      //       {
      //         fileName: "个人信息查询与使用授权书20230201191415.pdf",
      //         uploadTime: "20230201191423",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgGm8MdfrfojaTwlungFCtI5EW7RwDFjkgB7EpRGkGXbKQvFyOiTzetTQIalNawUtL7/TA3duaVCLwMXN4Iwhj+INx8Dtpvrw1Y/9IURneEuwNnRKTbO7fct3JDIJEz871XU3xOmgs0P2sjNAD0F4iafDFVIyFUU1HyT9aGyVjuoDA0OFfAm4Ni10bkq2lzQggI+mhgtxH6rrnTauq/RqUE4kjJFzgch8deF0HK2mpoHTk+/gGNjvBG4TDwqmXkX1RcUCRx8QCIre4aHdvFLhtL0",
      //         fileType: "pdf"
      //       }
      //     ],
      //     imgType: "CONTRACT"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861615842.jpg",
      //         uploadTime: "20230220105338",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgGx8Nyl9QjhbzwlungFCtI5EW7RwDFjkgB7EpRGkGXbKQvFyOiTzetTQIalNawUtL7/TA3duaVCLzuIJ5fWnW/e3OxD29Du+RjoozT77vIh1IlFR70A2AsROLGjYKaUVSHU3xOmgs0P2rEXY9VZ9b/hjW2JrbQqhnyY+eVVleVnjez9AmkRh739o/GS3nTA8faaYYuwYwejl3Tauq/RqUE4kjJFzgch8deF0HK2mpoHTk+/gGNjvBG4284fVNgBrokCxfpaDQsKjIaHdvFLhtL0",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "MARRIAGE"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFixQSFHmvtTtGBTdp2gD4rugFWqIDTupHDnwQtpXFICjtCp9Obui3G1nusJA+aBXQ6vLnE1TYi1FfyHuzuNdblI+TaCfXxwmEtnlQBfltOU5b3t7OKO+yiw2Phl7zAKQ2dCgCOBjfITIdbUccD0T9Q9avGyAhShy3rzBdI0yIkK+NudVaE3+iU57syEEbLdsF65InjiPpaFOKS5DKi2ktfU+xcWTBcOHj+HoklumZ8hxNxK9lJZ9ThSPdDtt3iHY37NP7Li4GqWljMpzkNaodiexssdH1TdcU=",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "GUARANTEE"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFixQSFHmvtTtGBTdp2gD4rugFWqIDTupHDnwQtpXFICjtCp9Obui3G1nusJA+aBXQ6vLnE1TYi1FfyHuzuNdblI+TaCfXxwmEtnlQBfltOU5b3t7OKO+yiw2Phl7zAKQ2dCgCOBjfITIdbUccD0T9Q9avGyAhShy3rzBdI0yIkK+NudVaE3+iU57syEEbLdsF65InjiPpaFOKS5DKi2ktfU+xcWTBcOHj+HoklumZ8hxNxK9lJZ9ThSPdDtt3iHY37NP7Li4GqWljMpzkNaodiexssdH1TdcU=",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "RENT"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFixQSFHmvtTtGBTdp2gD4rugFWqIDTupHDnwQtpXFICjtCp9Obui3G1nusJA+aBXQ6vLnE1TYi1FfyHuzuNdblI+TaCfXxwmEtnlQBfltOU5b3t7OKO+yiw2Phl7zAKQ2dCgCOBjfITIdbUccD0T9Q9avGyAhShy3rzBdI0yIkK+NudVaE3+iU57syEEbLdsF65InjiPpaFOKS5DKi2ktfU+xcWTBcOHj+HoklumZ8hxNxK9lJZ9ThSPdDtt3iHY37NP7Li4GqWljMpzkNaodiexssdH1TdcU=",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "CLEAN_PRACTICE"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFixQSFHmvtTtGBTdp2gD4rugFWqIDTupHDnwQtpXFICjtCp9Obui3G1nusJA+aBXQ6vLnE1TYi1FfyHuzuNdblI+TaCfXxwmEtnlQBfltOU5b3t7OKO+yiw2Phl7zAKQ2dCgCOBjfITIdbUccD0T9Q9avGyAhShy3rzBdI0yIkK+NudVaE3+iU57syEEbLdsF65InjiPpaFOKS5DKi2ktfU+xcWTBcOHj+HoklumZ8hxNxK9lJZ9ThSPdDtt3iHY37NP7Li4GqWljMpzkNaodiexssdH1TdcU=",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "DUE_DILIGENCE"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFixQSFHmvtTtGBTdp2gD4rugFWqIDTupHDnwQtpXFICjtCp9Obui3G1nusJA+aBXQ6vLnE1TYi1FfyHuzuNdblI+TaCfXxwmEtnlQBfltOU5b3t7OKO+yiw2Phl7zAKQ2dCgCOBjfITIdbUccD0T9Q9avGyAhShy3rzBdI0yIkK+NudVaE3+iU57syEEbLdsF65InjiPpaFOKS5DKi2ktfU+xcWTBcOHj+HoklumZ8hxNxK9lJZ9ThSPdDtt3iHY37NP7Li4GqWljMpzkNaodiexssdH1TdcU=",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "VISIT"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "http://10.172.92.113:8001/SunECMDM/servlet/getFile?AjmWlyWrxgH08HLz4lfFUzwlungFCtI5EW7RwDFjkgB7EpRGkGXbKQvFyOiTzetTQIalNawUtL7/TA3duaVCL9OdlDWviucluVytzQWhGj9oNgWWCZt9K4Gm6uD7/PFFhKkZYfeNTGSk08zbqDKLncct/sR4JVyZzJoErjaapnkI6Kd/DXaScila3pbeKw9HFdN49cnd6YmaYYuwYwejl3Tauq/RqUE4DypdsPpE466mp4t+XnqOa0+/gGNjvBG48RyAH3BHUHqe3T4CTF0fcIaHdvFLhtL0",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "HOUSE_FUND"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFixQSFHmvtTtGBTdp2gD4rugFWqIDTupHDnwQtpXFICjtCp9Obui3G1nusJA+aBXQ6vLnE1TYi1FfyHuzuNdblI+TaCfXxwmEtnlQBfltOU5b3t7OKO+yiw2Phl7zAKQ2dCgCOBjfITIdbUccD0T9Q9avGyAhShy3rzBdI0yIkK+NudVaE3+iU57syEEbLdsF65InjiPpaFOKS5DKi2ktfU+xcWTBcOHj+HoklumZ8hxNxK9lJZ9ThSPdDtt3iHY37NP7Li4GqWljMpzkNaodiexssdH1TdcU=",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "TAX"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "https://fqxcxceshi.jlbank.com.cn/SunECMDM/servlet/getFile?AjmWlyWrxgFixQSFHmvtTtGBTdp2gD4rugFWqIDTupHDnwQtpXFICjtCp9Obui3G1nusJA+aBXQ6vLnE1TYi1FfyHuzuNdblI+TaCfXxwmEtnlQBfltOU5b3t7OKO+yiw2Phl7zAKQ2dCgCOBjfITIdbUccD0T9Q9avGyAhShy3rzBdI0yIkK+NudVaE3+iU57syEEbLdsF65InjiPpaFOKS5DKi2ktfU+xcWTBcOHj+HoklumZ8hxNxK9lJZ9ThSPdDtt3iHY37NP7Li4GqWljMpzkNaodiexssdH1TdcU=",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "SALARY"
      //   },
      //   {
      //     urls: [
      //       {
      //         fileName: "1676861601542.jpg",
      //         uploadTime: "20230220105324",
      //         url:
      //           "http://10.172.92.113:8001/SunECMDM/servlet/getFile?AjmWlyWrxgH08HLz4lfFUzwlungFCtI5EW7RwDFjkgB7EpRGkGXbKQvFyOiTzetTQIalNawUtL7/TA3duaVCL9OdlDWviucluVytzQWhGj9oNgWWCZt9K4Gm6uD7/PFFhKkZYfeNTGSk08zbqDKLncct/sR4JVyZzJoErjaapnkI6Kd/DXaScila3pbeKw9HFdN49cnd6YmaYYuwYwejl3Tauq/RqUE4DypdsPpE466mp4t+XnqOa0+/gGNjvBG48RyAH3BHUHqe3T4CTF0fcIaHdvFLhtL0",
      //         fileType: "jpg"
      //       }
      //     ],
      //     imgType: "OTHER"
      //   }
      // ];
      let type = Object.prototype.toString.call(list);
      if (type === "[object Object]") return;
      if ((this.productType == PRODUCTTYPE.JXD)) {
         // 吉享贷
        let keys = Object.keys(this.IMAGE_TYPE);
        let filterImg = list.filter(ele => keys.includes(ele.imgType));
        filterImg.forEach(v => {
          this.previewList[v.imgType] = v.urls.map(ele => {
            return ele.url;
          });
          this.imageAll[v.imgType] = [...v.urls];
        });

        console.log(this.imageAll, "吉享贷影像结果");
      } else if ((this.productType == PRODUCTTYPE.JYD)) {
        // 吉用贷
        const a = {
          HOUSE_FUND: "公积金",
          TAX: "个税",
          INCOME: "收入证明",
          VISIT_LOGO: '亲访照片',
          VISIT_UNIT: '亲访照片',
          VISIT_DOOR: '亲访照片',
          VISIT_GROUP: '亲访照片',
          VISIT_INSIDE: '亲访照片',
          VISIT_PROPERTY: '亲访照片',
          VISIT_FLOOR: '亲访照片'
        };
        let b = Object.assign({}, a, this.IMAGE_JYDTYPE);
        let keys = Object.keys(b);
        let filterImg = list.filter(ele => keys.includes(ele.imgType));
        filterImg.forEach(v => {
          const obj = {
            HOUSE_FUND: "公积金/个税/收入证明",
            TAX: "公积金/个税/收入证明",
            INCOME: "公积金/个税/收入证明"
          };
          if (obj[v.imgType]) {
            // this.jydPreviewList[v.imgType] = v.urls.map(ele => {
            //   return ele.url;
            // });

            this.jydimageAll["HOUSE_FUND_TAX_SALARY"] = [
              ...this.jydimageAll["HOUSE_FUND_TAX_SALARY"],
              ...v.urls
            ];
            if (v.urls && v.urls.length>0) {
              v.urls.forEach(url => {
                this.jydPreviewList['HOUSE_FUND_TAX_SALARY'].push(url.url)
              });
            }
          } else {
            console.log('>>>>>>>>>>>>>>>>>', v.imgType);
            if (v.imgType == 'VISIT_LOGO' || v.imgType == 'VISIT_UNIT' 
                || v.imgType == 'VISIT_DOOR' || v.imgType == 'VISIT_GROUP' || v.imgType == 'VISIT_INSIDE'
                || v.imgType == 'VISIT_PROPERTY' || v.imgType == 'VISIT_FLOOR' ) {
              // 如果是亲访子类
              console.log('是亲访子类：', v.imgType);
              if (v.urls && v.urls.length>0) {
                v.urls.forEach(url => {
                  this.jydimageAll['VISIT'].push(url)
                  this.jydPreviewList['VISIT'].push(url.url)
                });
              }
            } else {
              this.jydimageAll[v.imgType] = [...v.urls];
              this.jydPreviewList[v.imgType] = v.urls.map(ele => {
                return ele.url;
              });
            }
          }
        });
        console.log(this.jydimageAll, "吉用贷影像结果");
      }
    },
    // getContactList (data) {
    //   api.getContractAll({customerId: data.customerId}).then(res => {
    //     console.log(res, '协议影像')
    //     const { responseCode, data } = res
    //     if (responseCode === CONSTANT_OBJ.RES_SUCCESS) {
    //       let len = Object.keys(data)
    //       if (len.length > 0) {
    //         this.disposeContract(data)
    //       }
    //     }
    //   })
    // },
    disposeContract(list) {
      let type = Object.prototype.toString.call(list);
      if (type === "[object Object]") return;
      const reg = /[\u4e00-\u9fa5]/g;
      let filterRes = list.filter(v => v.imgType === "CONTRACT");
      if (filterRes.length === 0) return;
      filterRes[0].urls.forEach(ele => {
        if (ele.fileName.match(reg).join("") !== "贷前调查确认函") {
          this.contractType[
            ele.fileName.match(reg).join("")
          ] = ele.fileName.match(reg).join("");
          this.allContract[ele.fileName.match(reg).join("")] = [];
        }
      });
      filterRes[0].urls.forEach(ele => {
        if (ele.fileName.match(reg).join("") !== "贷前调查确认函") {
          this.allContract[ele.fileName.match(reg).join("")].push(ele);
        }
      });
      this.agreementActive = Object.keys(this.contractType)[0];
    }
  },
  computed: {
    ...mapState({
      approvalData: state => state.approval.approvalData,
      dicts: state => state.common.dicts
    })
  }
};
</script>

<style lang="less">
@import "../../../assets/css/global.less";
.case-detatil {
  width: 80vw;
  .case-detatil {
    .el-form-item--mini.el-form-item,
    .el-form-item--small.el-form-item {
      margin-bottom: 10px;
    }
  }
  .el-textarea.is-disabled .el-textarea__inner,
  .el-input.is-disabled .el-input__inner {
    color: @theme-color;
  }
}
</style>
